<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="h" uri="/syzg-html"%>
<!DOCTYPE html>
<html>
<body>
	<div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">新增信息</h4>
					<div class="btn-group"></div>
				</div>


				<div class="tabbable" id="tabs-445307">
					<ul class="nav nav-tabs">
						<li class="active"><a href="#picnews" data-toggle="tab">图片新闻</a>
						</li>
						<li><a href="#wordnews" data-toggle="tab">文字新闻</a></li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="picnews">
							<div class="modal-body" id="modalCore">
								<form class="form-horizontal" role="form" id="aeForm"
									name="aeForm">
									<fieldset>
										<!-- generate code start -->
										<!-- 图片新闻  -->
										<input type="hidden" id="type" name="type" value="pic"
											class="form-control" />
										<div class="form-group">
											<label class="col-sm-2 control-label" for="id">ID</label>
											<div class="col-sm-3">
												<input type="text" id="id" name="id" value="${news.id}"
													class="form-control" readonly="readonly" />
											</div>

											<label class="col-sm-2 control-label" for="newsColumnsId">所属栏目</label>
											<div class="col-sm-3">
												<input type="text" id="newsColumnsName"
													name="newsColumnsName" onclick="openColumns()"
													class="form-control" /> <input type="hidden"
													id="newsColumnsId" name="newsColumns.id" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="newstype">新闻分类</label>
											<div class="col-sm-3">
												<input type="text" id="newstype" onclick="openBasicData()"
													name="newstype" value="${news.newstype}"
													class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="title">新闻标题</label>
											<div class="col-sm-3">
												<input type="text" id="title" name="title"
													value="${news.title}" class="form-control" />
											</div>
										</div>

										<div class="form-group">

											<label class="col-sm-2 control-label" for="coverPath">封面图片</label>
											<div class="col-sm-3">
												<%--  <input type="text" id="coverPath" name="coverPath" value="${news.coverPath}" class="form-control" /> --%>
												<div class="col-sm-3">
													<div
														style="border: 1px #000 solid;width: 100px;height: 100px;cursor: hand;">
														<img src="${newscolumns.coverPath}" class="media-object"
															alt="选择图片" onclick="doSelectPic()">
													</div>
													<input type="hidden" id="coverPath" name="coverPath" />
												</div>
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="correspondent">通讯员</label>
											<div class="col-sm-3">
												<input type="text" id="correspondent" name="correspondent"
													value="${news.correspondent}" class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="photographer">摄影师</label>
											<div class="col-sm-3">
												<input type="text" id="photographer" name="photographer"
													value="${news.photographer}" class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="editor">编辑</label>
											<div class="col-sm-3">
												<input type="text" id="editor" name="editor"
													value="${news.editor}" class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="keyword">关键字</label>
											<div class="col-sm-3">
												<input type="text" id="keyword" name="keyword"
													value="${news.keyword}" class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="isTop">是否置顶</label>
											<div class="col-sm-3">
												<select name="isTop" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>


											</div>

											<label class="col-sm-2 control-label" for="isStriking">是否醒目</label>
											<div class="col-sm-3">
												<select name="isStriking" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="isCarousel">是否轮播</label>
											<div class="col-sm-3">
												<select name="isCarousel" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>
											</div>
											<label class="col-sm-2 control-label" for="showTime">开始展示时间</label>
											<div class="col-sm-3">
												<input type="text" id="showTime" name="showTime"
													value='2016-06-12 10:28:01' class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="content">新闻内容</label>
											<div class="col-sm-3">
												<textarea class="form-control" id="content" name="content"
													rows="3">${news.content}</textarea>
												<%--  <input type="text" id="content" name="content" value="${news.content}" class="form-control" /> --%>
											</div>
										</div>
										<!-- generate code end -->
									</fieldset>
								</form>
								<div id="treeDlg"></div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default"
										data-dismiss="modal">取消</button>
									<button type="button" class="btn btn-primary"
										onclick="submitSave('add');">保存</button>
								</div>
							</div>
						</div>
						<div class="tab-pane " id="wordnews">
							<div class="modal-body" id="modalCore">
								<form class="form-horizontal" role="form" id="aeForm2"
									name="aeForm2">

									<fieldset>
										<!-- generate code start -->
										<!-- 文字新闻  -->
										<input type="hidden" id="coverPath" name="coverPath" />
										<input type="hidden" id="type" name="type" value="word"
											class="form-control" />
										<div class="form-group">
											<label class="col-sm-2 control-label" for="id">ID</label>
											<div class="col-sm-3">
												<input type="text" id="id" name="id" value="${news.id}"
													class="form-control" readonly="readonly" />
											</div>

											<label class="col-sm-2 control-label" for="newsColumnsId">所属栏目</label>
											<div class="col-sm-3">
												<input type="text" id="newsColumnsName2"
													name="newsColumnsName" onclick="openColumns2()"
													class="form-control" /> <input type="hidden"
													id="newsColumnsId2" name="newsColumns.id" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="newstype">新闻分类</label>
											<div class="col-sm-3">
												<input type="text" id="newstype2" onclick="openBasicData2()"
													name="newstype" value="${news.newstype}"
													class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="title">新闻标题</label>
											<div class="col-sm-3">
												<input type="text" id="title" name="title"
													value="${news.title}" class="form-control" />
											</div>
										</div>

									

										<div class="form-group">
											<label class="col-sm-2 control-label" for="correspondent">通讯员</label>
											<div class="col-sm-3">
												<input type="text" id="correspondent" name="correspondent"
													value="${news.correspondent}" class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="photographer">摄影师</label>
											<div class="col-sm-3">
												<input type="text" id="photographer" name="photographer"
													value="${news.photographer}" class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="editor">编辑</label>
											<div class="col-sm-3">
												<input type="text" id="editor" name="editor"
													value="${news.editor}" class="form-control" />
											</div>

											<label class="col-sm-2 control-label" for="keyword">关键字</label>
											<div class="col-sm-3">
												<input type="text" id="keyword" name="keyword"
													value="${news.keyword}" class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="isTop">是否置顶</label>
											<div class="col-sm-3">
												<select name="isTop" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>


											</div>

											<label class="col-sm-2 control-label" for="isStriking">是否醒目</label>
											<div class="col-sm-3">
												<select name="isStriking" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="isCarousel">是否轮播</label>
											<div class="col-sm-3">
												<select name="isCarousel" class="form-control">
													<option value="0">否</option>
													<option value="1">是</option>
												</select>
											</div>
											<label class="col-sm-2 control-label" for="showTime">开始展示时间</label>
											<div class="col-sm-3">
												<input type="text" id="showTime" name="showTime"
													value='2016-06-12 10:28:01' class="form-control" />
											</div>
										</div>

										<div class="form-group">
											<label class="col-sm-2 control-label" for="content">新闻内容</label>
											<div class="col-sm-3">
												<textarea class="form-control" id="content" name="content"
													rows="3">${news.content}</textarea>
												<%--  <input type="text" id="content" name="content" value="${news.content}" class="form-control" /> --%>
											</div>
										</div>
										<!-- generate code end -->
									</fieldset>
								</form>
							</div>
							<div id="treeDlg2"></div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" 	data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-primary" onclick="test();">保存</button>
							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
	<script type="text/javascript">
		$('#aeForm').bootstrapValidator({
			message : 'This value is not valid',
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				newstype : {
					group : '.col-sm-3',
					message : 'The username is not valid',
					validators : {
						notEmpty : {
							message : '新闻分类不允许为空'
						},
						stringLength : {
							min : 2,
							max : 30,
							message : '长度必须在2-30个字符之间'
						}
					}
				},
				newsColumnsName : {
					group : '.col-sm-3',
					message : 'The username is not valid',
					validators : {
						notEmpty : {
							message : '栏目不允许为空'
						}
					}
				}
			}
		}).on('success.form.bv', function(e, data) {
			FormFunction.submitSave('add');
		});
		
		$('#aeForm2').bootstrapValidator({
			message : 'This value is not valid',
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				newstype : {
					group : '.col-sm-3',
					message : 'The username is not valid',
					validators : {
						notEmpty : {
							message : '新闻分类不允许为空'
						},
						stringLength : {
							min : 2,
							max : 30,
							message : '长度必须在2-30个字符之间'
						}
					}
				},
				newsColumnsName : {
					group : '.col-sm-3',
					message : 'The username is not valid',
					validators : {
						notEmpty : {
							message : '栏目不允许为空'
						}
					}
				}
			}
		}).on('success.form.bv', function(e, data) {
			$.post(saveAddUrl,$("#aeForm2").serialize(),function(data){
				var result = eval('(' + data + ')');
				if(result.success==true){
					$('#addModal').modal("hide");
					bootbox.alert("<h4>您的操作已成功</h4>", function(){
						document.forms[0].action=listUrl;
		    			document.forms[0].submit();
					});
				} else {
					bootbox.alert("<h4>操作失败,原因：" + result.webInfo.errorList + "</h4>", function(){});
				}
			});
		});
		
		function test() {
			$.post(saveAddUrl,$("#aeForm2").serialize(),function(data){
				var result = eval('(' + data + ')');
				if(result.success==true){
					$('#addModal').modal("hide");
					bootbox.alert("<h4>您的操作已成功</h4>", function(){
						document.forms[0].action=listUrl;
		    			document.forms[0].submit();
					});
				} else {
					bootbox.alert("<h4>操作失败,原因：" + result.webInfo.errorList + "</h4>", function(){});
				}
			});
		}
		
		function openColumns() {
			ModalUtil.showModal('treeDlg', treeNewsColumnsViewUrl,
					'treeNewsColumnsViewModal', function() {
						loadNewsColumnsData();
					});
		}
		
		function openColumns2() {
			ModalUtil.showModal('treeDlg2', treeNewsColumnsViewUrl,
					'treeNewsColumnsViewModal', function() {
						loadNewsColumnsData2();
					});
		}
		
		function openBasicData() {
			ModalUtil.showModal('treeDlg', treeBasicDataViewUrl,
					'treeBasicDataViewModal', function() {
						loadBasicDataData("newsType");
					});
		}
		
		function openBasicData2() {
			ModalUtil.showModal('treeDlg2', treeBasicDataViewUrl,
					'treeBasicDataViewModal', function() {
						loadBasicDataData2("newsType");
					});
		}
		
		function setColumnsValue(data) {
			$("#newsColumnsId").val(data.id);
			$("#newsColumnsName").val(data.text);
		}
		
		function setColumnsValue2(data) {
			$("#newsColumnsId2").val(data.id);
			$("#newsColumnsName2").val(data.text);
		}
		
		function setBasicDataValue(data) {
			$("#newstype").val(data.text);
			//$("#newsColumnsName").val(data.text);
		}
		
		function setBasicDataValue2(data) {
			$("#newstype2").val(data.text);
			//$("#newsColumnsName").val(data.text);
		}
	</script>
</body>
</html>

